
app.controller('exportExcelCtrl', function($element, $scope, $state, rest, user, uploadConf, tipService, $window, $rootScope,decoJavaUrlLsf) {
	$scope.idstring = angular.copy($scope.ngDialogData, {});
	var token = $window.localStorage.getItem("token");
	
	rest.decoJava({
		type: "post",
        url: "/tenancy-sys/contract-resource/contract/configparam",
        data: "",
        beforeSend: function(request) {
            request.setRequestHeader("token", token);
        },
        success: function(res) {
        	$scope.ExcelDatas = res;
        	$scope.$apply();
        	$("#_ajaxForm").attr("action",decoJavaUrlLsf+"/tenancy-sys/contract-resource/contracts/exportlandlordexcel"); //form请求地址
        }
	})
	
	
	$(document).on("click",".checkboxBar input[type='checkbox']",function(){
		var index = $(this).attr("data-index");
		if($(this).is(":checked")){
			$(".checkboxBar2 input[data-index='"+index+"']").prop("checked",true);
		} else{
			$(".checkboxBar2 input[data-index='"+index+"']").prop("checked",false);
		}
		
		//数据处理1
        var keysArr = [];
        angular.element(".checkboxBar input[type='checkbox']").each(function() {
            if ($(this).is(":checked")) {
                keysArr.push($(this).val());
            }
        });
        var _keysstring = "";
        angular.forEach(keysArr, function(data) {
            _keysstring += data + ',';
        })
        var _keysstring = _keysstring.substring(0, _keysstring.length - 1);
        //数据处理2
        var colArr = [];
        angular.element(".checkboxBar2 input[type='checkbox']").each(function() {
            if ($(this).is(":checked")) {
                colArr.push($(this).val());
            }
        });
        var colstring = "";
        angular.forEach(colArr, function(data) {
            colstring += data + ',';
        })
        var colstring = colstring.substring(0, colstring.length - 1);
        $scope.keysstring = _keysstring
        $scope.colstring = colstring
        $scope.$apply();
		
	});
	
	$scope.exportData = function(){
		if($scope.keysstring == "" || $scope.keysstring == undefined){
			layer.msg("没有选中项", {
                offset: 't',
                icon: 2
            });
		} else{
			$("#_ajaxForm").submit();
		}
	}
	
    $scope.hideBtn = function(){
    	$scope.closeThisDialog();
    }
    
    //全部选中和取消
    $scope.allMenus = function(e){
    	var This = angular.element(e.target);
    	if(This.is(":checked")){
    		angular.element(".checkchilds").prop("checked",true);
    	} else{
    		angular.element(".checkchilds").prop("checked",false);
    	}
    	
    	//数据处理1
        var keysArr = [];
        angular.element(".checkboxBar input[type='checkbox']").each(function() {
            if ($(this).is(":checked")) {
                keysArr.push($(this).val());
            }
        });
        var _keysstring = "";
        angular.forEach(keysArr, function(data) {
            _keysstring += data + ',';
        })
        var _keysstring = _keysstring.substring(0, _keysstring.length - 1);
        //数据处理2
        var colArr = [];
        angular.element(".checkboxBar2 input[type='checkbox']").each(function() {
            if ($(this).is(":checked")) {
                colArr.push($(this).val());
            }
        });
        var colstring = "";
        angular.forEach(colArr, function(data) {
            colstring += data + ',';
        })
        var colstring = colstring.substring(0, colstring.length - 1);
        $scope.keysstring = _keysstring
        $scope.colstring = colstring
        //$scope.$apply();
    }
    
});
